/*
 * Logger.h
 *
 *  Created on: Oct 22, 2008
 *      Author: Ryan
 */

#ifndef LOGGER_H_
#define LOGGER_H_

#include "Object.h"

#include <string>
#include <fstream>
#include <map>

namespace OOInterface
{

class Logger
{
public:
	Logger( const Logger& l );

	static Logger& getInstance( std::string filename );
	static Logger& getInstance( const char* filename );
	virtual ~Logger();

	static void closeAll();

	Logger& operator<<( const Object& rhs );
	Logger& operator<<( const char* rhs );
	Logger& operator<<( const std::string rhs );


	Logger& operator<<( bool rhs );
	Logger& operator<<( short rhs );
	Logger& operator<<( unsigned short rhs );
	Logger& operator<<( int rhs );
	Logger& operator<<( unsigned int rhs );
	Logger& operator<<( long val );
	Logger& operator<<( unsigned long val );
	Logger& operator<<( float rhs );
	Logger& operator<<( double rhs );
	Logger& operator<<( long double rhs );
	Logger& operator<<( void* val );
	Logger& operator<<( std::ostream& (*rhs) (std::ostream&) );

private:
	Logger( std::string filename );
	bool open();

	std::string _filename;
	std::ofstream* _stream;

	typedef std::map< std::string, Logger > LoggerMap;
	static LoggerMap _loggers;
};

}

#endif /* LOGGER_H_ */
